package org.supreme.filter;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FilterConfig {
    @Bean
    public RouteLocator customerRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes().route(r -> r.path("/pay/**")
                //去掉1个前缀
                .filters(f -> f.stripPrefix(1)
                        .filter(new RequestTimeFilter())
                        )
                .uri("lb://pay-server")
                .order(0)
                .id("test-RequestTimeFilter")
        ).build();
    }
}

